package com.ksv.qlsv;

import com.ksv.lop.AddAdapter;
import com.ksv.lop.ConnectDB;
import com.ksv.lop.KetQuaAdapter;
import com.ksv.lop.SinhVien;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Spinner;

public class SinhVienXemDiemActivity extends Activity {
	
	public static SinhVien sv = null;
	private ListView lv_ket_qua;
	private Spinner com_hoc_ky;
	private KetQuaAdapter ketquaAdapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialogedit_sv_xemdiem);          
        this.setTitle(sv.getHoTen());
        lv_ket_qua = (ListView)findViewById(R.id.lv_ket_qua);
        com_hoc_ky = (Spinner)findViewById(R.id.com_hocky);
        loadListHocKy();
        loadListKetQua();
	}
	
	private void loadListKetQua(){
    	try{
//    		lv_ket_qua.setAdapter(null);
    	    Cursor c = ConnectDB.getAllMonHoc();
    	    KetQuaAdapter.mID = ConnectDB.mamon;
    	    KetQuaAdapter.mName = ConnectDB.tenmon;
    	    ketquaAdapter = new KetQuaAdapter(this, c);
    	    lv_ket_qua.setAdapter(ketquaAdapter);
    	}
    	catch(Exception ex){
    		
    	}
    }
	
	private void loadListHocKy() {
		Cursor c = ConnectDB.getAllHocKy();
		startManagingCursor(c);
		SimpleCursorAdapter ca = new SimpleCursorAdapter(this,R.layout.listrow_diem, c, new String [] {ConnectDB.tenhk,"_id"}, new int []{R.id.txt_name});
		com_hoc_ky.setAdapter(ca);
		com_hoc_ky.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View selectedView,
					int position, long id) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	
}
